#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=500000;

class SAM {
public:
  int n, size[2*maxn+1], cnt[2*maxn+1], step[2*maxn+1], pre[2*maxn+1], son[2*maxn+1][26], in[2*maxn+1], last;

  SAM() {
    pre[0] = -1, n=0, last=0;
  }

  void addChar(char c) {
    int np=++n, nq, p=last, q;
    step[np] = step[last]+1;
    for (;p>=0 && !son[p][c-'a']; p=pre[p]) {
      son[p][c-'a'] = np;
      in[np]++;
    }
    if (p<0) {
      pre[np] = 0;
    } else {
      q = son[p][c-'a'];
      if (step[q]==step[p]+1) {
	pre[np] = q;
      } else {
	nq=++n;
	pre[nq] = pre[q];
	step[nq] = step[p]+1;
	memcpy(son[nq], son[q], sizeof son[q]);
	pre[q] = pre[np] = nq;
	son[p][c-'a'] = nq;
	in[q]--;
	in[nq]++;
	for (p=pre[nq]; p; p=pre[p]) {
	  if (son[p][c-'a']==q) {
	    in[nq]++;
	    in[q]--;
	    son[p][c-'a'] = nq;
	  }
	}
      }
    }
    last = np;
  }

  void calcCnt1() {
    for (int i=1; i<=n; i++) {
      cnt[i] = 1;
    }
  }

  void calcCnt2() {
    for (int i=n; i>=0; i--) {
      cnt[i] = 1;
      cnt[pre[i]] += cnt[i];
    }
  }

  void calcSize() {
    static int que[2*maxn+1];
    que[0] = 0;
    int h=0, t=0;
    for (int i=0; i<=n; i++) {
      if (!in[i]) {
	que[++t] = i;
      }
    }
    for (; h<t; ) {
      int x=que[++h];
      for (int i=0; i<26; i++) {
	if (son[x][i]) {
	  in[son[x][i]]--;
	  if (!in[son[x][i]]) {
	    que[++t] = son[x][i];
	  }
	}
      }
    }
    for (int i=t; i>0; i--) {
      size[que[i]] = cnt[que[i]];
      for (int j=0; j<26; j++) {
	if (son[que[i]][j]) {
	  size[que[i]] += size[son[que[i]][j]];
	}
      }
    }
  }

  void solve(int o, int sum, int k, char *ans) {
    sum+=cnt[o];
    if (sum==k) {
      return;
    }
    for (int i=0; i<26; i++) {
      if (son[o][i]) {
	if (sum+size[son[o][i]]<k) {
	  sum += size[son[o][i]];
	} else {
	  *ans = i+'a';
	  solve(son[o][i], sum, k, ans+1);
	  return;
	}
      }
    }
  }
};

int main() {
  freopen("string.in", "r", stdin);
  freopen("string.out", "w", stdout);

  static SAM sam;
  static char s[maxn+1], ans[maxn+1];
  int t, k;
  scanf("%s %d %d", s, &t, &k);
  for (int i=0; s[i]!='\0'; i++) {
    sam.addChar(s[i]);
  }

  t==0 ? sam.calcCnt1() : sam.calcCnt2();
  sam.calcSize();
  if (sam.size[0]<k) {
    printf("%d", -1);
  } else {
    sam.solve(0, 0, k, ans);
    printf("%s", ans);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
